/*
 * @Title: 我的拼团
 * @Author: JSL
 * @Date:   2018-10-26
 * @Last Modified by:   JSL
 * @Last Modified time: 2018-10-26
 */
var dataInfo = {},
  template = {
    init: function() {
      dataInfo.init = new Vue({
        el: '#app',
        data: {
          tabData: [{
            name: '全部',
          }, {
            name: '拼团中',
          }, {
            name: '拼团成功',
          }, {
            name: '拼团失败',
          }],
          listData: [],
          listLength: 1,
          active: 0,
          loading: false,
          isLoading: false,
          finished: false,
          page: 1,
          showNum: 0
        },
        methods: {
          onLoad: function() {
            this.listLength > this.listData.length ? this.getList() : '';
            this.loading = false;
            this.isLoading = false;
          },
          onRefresh: function() { //下拉刷新
            this.page = 1;
            this.listData = [];
            dataInfo.init.getList();
            setTimeout(function() {
              dataInfo.init.loading = false;
              dataInfo.init.isLoading = false;
            }, 500);
          },
          getList: function() {
            ajaxTemplate(addressTest + SERVICE.ptOrderList, function(data) {
              console.log(data);
              if (data.tag == 0) {
                dataInfo.init.listLength = data.data.result.orderList.total;
                dataInfo.init.listData = dataInfo.init.listData.concat(data.data.result.orderList.data);
                dataInfo.init.showNum = dataInfo.init.listData.length;
              } else {
                dataInfo.init.$toast(data.errMsg);
                if (data.errMsg == '请求参数[access_token]不能为空！') {
                  jumpLogin();
                };
              };
            }, {
              userId: userId,
              grouponOrderStatus: !this.active ? '' : this.active - 1,
              pageNo: this.page++,
              pageSize: 5
            });
          },
        },
        watch: {
          active: function(e) {
            this.page = 1;
            this.showNum = 1;
            this.listData = [];
            document.body.scrollTop = 0;
            document.documentElement.scrollTop = 0;
            dataInfo.init.getList();
          }
        }
      });
      //初始化函数
    },
  };
template.init();
